package com.liangsui.mss.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liangsui.mss.domain.InventoryLog;
import com.liangsui.mss.dto.InventoryLogDto;
import com.liangsui.mss.mapper.InventoryLogMapper;
import com.liangsui.mss.service.InventoryLogService;
import com.liangsui.mss.vo.DataGridView;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author zhang
* @description 针对表【stock_inventory_log】的数据库操作Service实现
* @createDate 2022-12-06 14:18:42
*/
@DubboService
public class InventoryLogServiceImpl extends ServiceImpl<InventoryLogMapper, InventoryLog>
    implements InventoryLogService{

    @Autowired
    private InventoryLogMapper inventoryLogMapper;

    @Override
    public DataGridView listInventoryLogPage(InventoryLogDto inventoryLogDto) {
        Page<InventoryLog> page=new Page<>(inventoryLogDto.getPageNum(), inventoryLogDto.getPageSize());
        QueryWrapper<InventoryLog> qw=new QueryWrapper<>();
        qw.like(StringUtils.isNotBlank(inventoryLogDto.getPurchaseId()),
                InventoryLog.COL_PURCHASE_ID, inventoryLogDto.getPurchaseId());
        qw.like(StringUtils.isNotBlank(inventoryLogDto.getMedicinesName()),
                InventoryLog.COL_MEDICINES_NAME, inventoryLogDto.getMedicinesName());
        qw.eq(StringUtils.isNotBlank(inventoryLogDto.getMedicinesType()),
                InventoryLog.COL_MEDICINES_TYPE, inventoryLogDto.getMedicinesType());
        qw.eq(StringUtils.isNotBlank(inventoryLogDto.getProducterId()),
                InventoryLog.COL_PRODUCTER_ID, inventoryLogDto.getProducterId());
        qw.eq(StringUtils.isNotBlank(inventoryLogDto.getPrescriptionType()),
                InventoryLog.COL_PRESCRIPTION_TYPE, inventoryLogDto.getPrescriptionType());
        qw.ge(inventoryLogDto.getBeginTime()!=null,
                InventoryLog.COL_CREATE_TIME, inventoryLogDto.getBeginTime());
        qw.le(inventoryLogDto.getEndTime()!=null,
                InventoryLog.COL_CREATE_TIME, inventoryLogDto.getEndTime());
        qw.orderByDesc(InventoryLog.COL_CREATE_TIME);
        this.inventoryLogMapper.selectPage(page, qw);
        return new DataGridView(page.getTotal(), page.getRecords());
    }
}




